package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Phone    string `gorm:"column:phone;type:varchar(11);not null;comment:手机号"`
	Password string `gorm:"column:password;type:varchar(20);not null;comment:密码"`
}
type RealAuth struct {
	gorm.Model
	UserId   int    `gorm:"column:user_id;type:int;not null;unique;comment:用户ID"`
	IdCard   string `gorm:"column:id_card;type:varchar(18);not null;comment:身份证号"`
	RealName string `gorm:"column:real_name;type:varchar(10);not null;comment:真实姓名"`
}

// 创建User表
func (u *User) CreateUser() error {
	return mysqlClient.Create(&u).Error
}

// 查询用户ID
func (r *RealAuth) FindUserId() error {
	return mysqlClient.Where("userId = ?", r.UserId).First(&r).Error
}

// 查询身份证号
func (r *RealAuth) FindIdCard() error {
	return mysqlClient.Where("idCard = ?", r.IdCard).First(&r).Error
}

// 创建RealAuth表
func (r *RealAuth) CreateRealAuth() error {
	return mysqlClient.Create(&r).Error
}
